﻿namespace ExamV5.ManagSys
{
    using ExamV5;
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class ManagSysMenu : Page
    {
        protected Button butDefault;
        protected Button butDel;
        protected Button butSys;
        protected DropDownList DDLMenuType;
        protected DropDownList DDLUPMenu;
        protected HtmlForm form1;
        protected HtmlHead Head1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        private HttpCookie httpCookie_4 = null;
        protected Label labID;
        private PublicFun publicFun_0 = new PublicFun();
        protected RadioButtonList RBLChildIsHide;
        protected RadioButtonList RBLChildMenuTrget;
        protected RadioButtonList RBLLookType;
        protected ScriptManager SM;
        protected string strBrowUserCode = "";
        protected string strBrowUserName = "";
        protected string strCMenuICO = "";
        protected string strCMenuICOFile = "";
        protected string strID = "0";
        //protected TreeView TreeMenu;
        protected TextBox txtMenuName;
        protected TextBox txtMenuURL;
        protected TextBox txtSortInfo;
        protected UpdatePanel UPPart;

        protected Label lblTreeType;
        protected void butDefault_Click(object sender, EventArgs e)
        {
            if ((this.labID.Text.Trim() == "0") || (this.labID.Text != this.DDLUPMenu.SelectedItem.Value))
            {
                string str2 = "";
                string str3 = "";
                str2 = base.Request.Form["txtBrowUserCode"].ToString();
                str3 = base.Request.Form["txtBrowUserName"].ToString();
                string str4 = base.Request.Form["txtCMenuICO"].ToString();
                this.strCMenuICOFile = str4.Replace("[object Window]", "");
                this.strCMenuICO = str4.Replace("[object Window]", "");
                if (str2.Trim() != "")
                {
                    str2 = "," + str2 + ",";
                    str3 = "," + str3 + ",";
                }
                else
                {
                    str2 = ",所有人员,";
                    str3 = ",所有人员,";
                }
                string strSql = "";
                if (this.labID.Text == "0")
                {
                    strSql = "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('" + this.publicFun_0.CheckString(this.txtMenuName.Text) + "','" + this.txtMenuURL.Text.Trim() + "','" + this.DDLUPMenu.SelectedItem.Value + "','" + this.txtSortInfo.Text + "','" + this.RBLChildMenuTrget.SelectedItem.Value + "','" + this.RBLChildIsHide.SelectedItem.Value + "','" + this.strCMenuICO + "','" + str2 + "','" + str3 + "','" + this.RBLLookType.SelectedItem.Value + "');insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('新增[" + this.publicFun_0.CheckString(this.txtMenuName.Text) + "]系统菜单信息！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')";
                }
                else
                {
                    strSql = "update SysMenu set IsShow='" + this.RBLLookType.SelectedItem.Value + "',TrgetFlag='" + this.RBLChildMenuTrget.SelectedItem.Value + "',IsHide='" + this.RBLChildIsHide.SelectedItem.Value + "',MenuICO='" + this.strCMenuICO + "',MenuTitle='" + this.publicFun_0.CheckString(this.txtMenuName.Text) + "',MenuURL='" + this.txtMenuURL.Text.Trim() + "',BrowUserCode='" + str2 + "',BrowUserName='" + str3 + "',MenuSort='" + this.txtSortInfo.Text + "',UPID='" + this.DDLUPMenu.SelectedItem.Value + "' where ID=" + this.labID.Text + ";insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('编辑[" + this.publicFun_0.CheckString(this.txtMenuName.Text) + "]系统菜单信息！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')";
                }
                this.publicFun_0.ExecuteSql(strSql);
                this.butDefault.Text = "新 增";
                this.strID = "0";
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('编辑系统菜单信息操作成功！');setTimeout(function(){window.location='ManagSysMenu.aspx'},500)", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('上级菜单名称不可以为当前菜单名称！')", true);
            }
        }

        protected void butDel_Click(object sender, EventArgs e)
        {
            if (!(this.labID.Text.Trim() != "0"))
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('请选择需要删除的系统菜单信息！')", true);
            }
            else if (!(this.publicFun_0.GetValues("select ID from SysMenu where UPID=" + this.labID.Text.Trim(), "ID") == ""))
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此系统菜单中还存在子菜单信息,无法删除！')", true);
            }
            else
            {
                this.publicFun_0.ExecuteSql("Delete from SysMenu where ID=" + this.labID.Text.Trim() + ";insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('删除[" + this.publicFun_0.CheckString(this.txtMenuName.Text) + "]系统菜单信息！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('删除系统菜单信息操作成功！');setTimeout(function(){window.location='ManagSysMenu.aspx'},500)", true);
            }
        }

        protected void butSys_Click(object sender, EventArgs e)
        {
            if (this.ViewState["UserPower"].ToString() == "Y")
            {
                string str = "truncate table SysMenu;";
                str = (((((((((((((((((((str + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('个人信息中心','',0,1,'N','N','Image/MenuICO/Menu37.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('在线交流平台','',0,2,'N','N','Image/MenuICO/Choose61.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('学习培训中心','',0,3,'N','N','Image/MenuICO/Menu6.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('练习考试中心','',0,4,'N','N','Image/MenuICO/Menu15.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('学习培训管理','',0,1,'N','N','Image/MenuICO/Menu48.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('考试信息管理','',0,2,'N','N','Image/MenuICO/Menu62.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('系统信息设置','',0,4,'N','N','Image/MenuICO/Menu25.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('我的个人信息','Persion/EditPersionInfo.aspx',1,1,'N','N','Image/MenuEditSelfAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('我的学习进度','Persion/StudyingList.aspx',1,2,'N','N','Image/MenuDataAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('我的成绩学分','Persion/ExamHistoryList.aspx',1,3,'N','N','Image/MenuExamAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow)values('我的学习笔记','Persion/FrmMyStudyLogList.aspx',1,3,'N','N','Image/MenuRubricAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('我的职业测评','WorkExam/FrmMyWorkExamList.aspx',1,4,'N','N','Image/MenuStudyAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('求助信息列表','Persion/HelpInfoList.aspx',1,5,'N','N','Image/MenuHelpAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('新闻公告中心','OnLineInter/NewsInfoList.aspx',2,5,'N','N','Image/MenuNewsAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('在线交流论坛','OnLineInter/ForumInfoList.aspx',2,6,'N','N','Image/MenuForumAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('在线调查中心','OnLineInter/FrmDCUserList.aspx',2,7,'N','N','Image/MenuQuestionAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('学习任务中心','StudyInfo/FrmStudyList.aspx',3,8,'N','N','Image/MenuMemberAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('电子教材中心','StudyInfo/FrmShowStudy.htm',3,9,'N','N','Image/MenuBookAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('电子课件中心','StudyInfo/FrmShowLession.htm',3,10,'N','N','Image/MenuLessionAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('在线练习中心','LineStudyExam/TaskInfo.aspx',4,11,'N','N','Image/MenuPaperAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('自我模拟考试','LineStudyExam/TestExamList.aspx',4,12,'N','N','Image/MenuRubricAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('在线考试中心','LineStudyExam/ExamInfoList.aspx',4,13,'N','N','Image/MenuEnterSydAA.gif',',所有人员,',',所有人员,','A');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('汉字输入考核','ZiExam/ExamInput.aspx',4,14,'N','N','Image/MenuZiExamAA.gif',',所有人员,',',所有人员,','A');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('电子教材管理','StudyInfo/ManagSubject.htm',5,1,'N','N','Image/MenuBookAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('电子课件管理','StudyInfo/ManagLession.htm',5,2,'N','N','Image/MenuLessionAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('定制学习任务','StudyInfo/PlanList.aspx',5,3,'N','N','Image/MenuStudyAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('学员学习进度','StudyInfo/FrmUserStudying.aspx',5,4,'N','N','Image/MenuDataAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('考试题库管理','RubricInfo/QueryRubricInfo.aspx',6,5,'N','N','Image/MenuRubricAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('试卷信息管理','PaperInfo/RndAddPaper.aspx',6,6,'N','N','Image/MenuPaperAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('在线监考中心','OnlineExam/ExamList.aspx',6,7,'N','N','Image/MenuLookExamAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('人工批卷阅卷','CheckPaper/CheckPaperList.aspx',6,8,'N','N','Image/MenuCheckAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('考试成绩管理','GradeInfo/QueryGradeList.aspx',6,9,'N','N','Image/MenuMyGradeAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('职业测评管理','WorkExam/FrmWorkRubricList.aspx',6,10,'N','N','Image/MenuAtedbAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('打字考试管理','ZiExam/RubricList.aspx',6,11,'N','N','Image/MenuZiExamAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('人员信息管理','ManagSys/ManagUserList.aspx',7,12,'N','N','Image/MenuUserAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('会员信息管理','ManagSys/FrmMemberList.aspx',7,13,'N','N','Image/MenuMemberAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('考试科目管理','ManagSys/ManagSubjectInfo.aspx',7,14,'N','N','Image/MenuInfoAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('成绩档案设置','ManagSys/ManagArchiveInfo.aspx',7,15,'N','N','Image/MenuFloderAA.gif',',所有人员,',',所有人员,','C');") + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('系统综合设置','ManagSys/ManagSetSys.aspx',7,16,'N','N','Image/MenuSysSetAA.gif',',所有人员,',',所有人员,','C');" + "insert into SysMenu(MenuTitle,MenuURL,UPID,MenuSort,TrgetFlag,IsHide,MenuICO,BrowUserCode,BrowUserName,IsShow) values('系统菜单管理','ManagSys/ManagSysMenu.aspx',7,17,'N','N','Image/MenuStudyingAA.gif',',所有人员,',',所有人员,','C');";
                this.publicFun_0.ExecuteSql(str + ";insert into SysLogInfo(LogDisp,EditUser,EditUserCode) values('还原系统菜单操作！','" + this.httpCookie_1.Value + "','" + this.httpCookie_0.Value + "')");
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('还原系统菜单操作成功,建议重新登录或按F5刷新！')", true);
            }
        }

        protected void DDLMenuType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.DDLMenuType.SelectedItem.Value == "M")
            {
                this.txtMenuURL.Text = "";
                this.txtMenuURL.Enabled = false;
            }
            if (this.DDLMenuType.SelectedItem.Value == "C")
            {
                this.txtMenuURL.Enabled = true;
            }
            this.strBrowUserCode = "所有人员";
            this.strBrowUserName = "所有人员";
            this.txtSortInfo.Text = "1";
            this.strCMenuICO = "";
            this.strCMenuICOFile = "";
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        private void method_0()
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select ID,MenuTitle from SysMenu where UPID=0 order by IsShow,MenuSort", connection);
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                this.DDLUPMenu.Items.Add(new ListItem(reader["MenuTitle"].ToString(), reader["ID"].ToString()));
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        private void method_1(string string_0, int int_0)
        {
            string text = "";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select ID,MenuTitle from SysMenu where UPID=" + string_0 + " order by MenuSort,ID", connection);
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                text = "";
                for (int i = 0; i < int_0; i++)
                {
                    if (i >= (int_0 - 1))
                    {
                        text = text + "├";
                    }
                    else
                    {
                        text = text + "│";
                    }
                }
                text = text + reader["MenuTitle"].ToString();
                this.DDLUPMenu.Items.Add(new ListItem(text, reader["ID"].ToString()));
                this.method_1(reader["ID"].ToString(), int_0 + 1);
            }
            connection.Dispose();
            command.Dispose();
            connection.Close();
            reader.Close();
        }

        private void method_2(string string_0, TreeNode treeNode_0, string string_1, string string_2)
        {
            //TreeNode child = new TreeNode {
            //    Value = string_1,
            //    Text = string_0,
            //    ToolTip = string_2
            //};
            //if ((string_2 != "0") && !(string_0 == "系统菜单信息管理"))
            //{
            //    treeNode_0.ChildNodes.Add(child);
            //    treeNode_0.Expanded = false;
            //}
            //else
            //{
            //    this.TreeMenu.Nodes.Add(child);
            //    treeNode_0.Expanded = true;
            //}
            //string cmdText = "select ID,MenuTitle,UPID from SysMenu where UPID='" + string_1 + "' order by IsShow,MenuSort";
            //SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            //SqlCommand command = new SqlCommand(cmdText, connection);
            //connection.Open();
            //SqlDataReader reader = command.ExecuteReader();
            //while (reader.Read())
            //{
            //    this.method_2(reader["MenuTitle"].ToString(), child, reader["ID"].ToString(), reader["UPID"].ToString());
            //}
            //reader.Close();
            //connection.Close();
            //connection.Dispose();
        }
        private void method_2(string string_0, string string_1, string string_2)
        {
            if (string_0 == "系统菜单信息管理")
            {
                this.lblTreeType.Text += "<ul id=\"red\" class=\"treeview-red\">";
            }
            else
            {
                this.lblTreeType.Text += "<ul>";
            }
            string cmdText = "select ID,MenuTitle,UPID from SysMenu where UPID='" + string_1 + "' order by IsShow,MenuSort";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            SqlCommand command = new SqlCommand(cmdText, connection);
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            while (reader.Read())
            {
                var name = reader["MenuTitle"].ToString();
                var id = reader["ID"].ToString();
                var upid = reader["UPID"].ToString();
                this.lblTreeType.Text += $"<li><span><a style=\"cursor:pointer\" onclick=\"TreeClicked('{name}','{id}','{upid}')\">{name}</a></span>";
                this.method_2(name, id, upid);
                this.lblTreeType.Text += "</li>";
            }
            reader.Close();
            connection.Close();
            connection.Dispose();

            this.lblTreeType.Text += "</ul>";
            this.lblTreeType.Text = this.lblTreeType.Text.Replace("<ul></ul>", "");
            this.lblTreeType.Text = this.lblTreeType.Text.Replace("<ul id=\"red\" class=\"treeview-red\"></ul>", "");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_3 = new HttpCookie("ExamUserLevel");
            this.httpCookie_3 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_4 = new HttpCookie("ExamDeptID");
            this.httpCookie_4 = base.Request.Cookies["ExamDeptID"];
            this.httpCookie_2 = new HttpCookie("ExamDeptName");
            this.httpCookie_2 = base.Request.Cookies["ExamDeptName"];
            if ((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false)
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                this.httpCookie_4.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_4.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                if (!base.IsPostBack)
                {
                    if (this.publicFun_0.ReturnPaperData() != "Yes")
                    {
                        ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BCheck", "alert('此版本暂未授权,请拔打(0)13870606104手机号进行授权！')", true);
                    }
                    else
                    {
                        this.ViewState["UserPower"] = this.publicFun_0.GetValues("select ManagMenu from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagMenu");
                        this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString;
                        this.DDLUPMenu.Items.Clear();
                        if (this.ViewState["UserPower"].ToString() == "Y")
                        {
                            this.method_0();
                            this.DDLUPMenu.SelectedIndex = -1;
                            ListItem item = new ListItem("系统顶级菜单", "0");
                            this.DDLUPMenu.Items.Insert(0, item);
                        }
                        this.lblTreeType.Text = string.Empty;
                        //this.TreeMenu.Nodes.Clear();
                        //TreeNode node = new TreeNode();
                        if (this.ViewState["UserPower"].ToString() == "Y")
                        {
                            //this.method_2("系统菜单信息管理", node, "0", "0");
                            this.method_2("系统菜单信息管理", "0", "0");
                        }
                        this.butDel.Attributes.Add("onclick", "javascript:{if(confirm('确定要删除吗？')==false) return false;}");
                        this.butSys.Attributes.Add("onclick", "javascript:{if(confirm('确定要还原恢复系统菜单吗？')==false) return false;}");
                        this.strBrowUserCode = "所有人员";
                        this.strBrowUserName = "所有人员";
                        this.txtSortInfo.Text = "1";
                        this.strCMenuICO = "";
                        this.strCMenuICOFile = "";
                        this.butDefault.Text = "新 增";
                        this.strID = "0";
                    }
                }
                else
                {
                    this.strBrowUserCode = base.Request.Form["txtBrowUserCode"].ToString();
                    this.strBrowUserName = base.Request.Form["txtBrowUserName"].ToString();
                    this.strCMenuICOFile = base.Request.Form["txtCMenuICO"].ToString();
                    this.strCMenuICO = base.Request.Form["txtCMenuICO"].ToString();
                }
            }
            else
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
        }

        protected void btnGet_Click(object sender, EventArgs e)
        {
            var name = base.Request.Form["txtTypeName"].ToString();
            var id = base.Request.Form["txtTypeId"].ToString();
            var upid = base.Request.Form["txtTypeUPId"].ToString();
            this.ShowData(name, id, upid);
            ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "Render", "LayaUIFormRender();", true);
        }

        public void ShowData(string name, string id, string upid)
        {
            if (!(name != "系统菜单信息管理"))
            {
                this.DDLUPMenu.SelectedIndex = 0;
                this.DDLMenuType.SelectedIndex = 0;
                this.RBLLookType.SelectedIndex = 0;
                this.RBLChildMenuTrget.SelectedIndex = 0;
                this.RBLChildIsHide.SelectedIndex = 0;
                this.txtMenuURL.Text = "";
                this.txtMenuName.Text = "";
                this.labID.Text = "0";
                this.strBrowUserCode = "所有人员";
                this.strBrowUserName = "所有人员";
                this.strCMenuICO = "";
                this.strCMenuICOFile = "";
                this.txtSortInfo.Text = "1";
                this.butDefault.Text = "新 增";
                this.strID = this.labID.Text;
            }
            else
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                connection.Open();
                SqlCommand command = new SqlCommand("select * from SysMenu where ID='" + id.Trim() + "'", connection);
                SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    this.DDLUPMenu.SelectedIndex = -1;
                    this.DDLMenuType.SelectedIndex = -1;
                    this.RBLLookType.SelectedIndex = -1;
                    this.RBLChildMenuTrget.SelectedIndex = -1;
                    this.RBLChildIsHide.SelectedIndex = -1;
                    this.DDLUPMenu.Items.FindByValue(reader["UPID"].ToString()).Selected = true;
                    if (!(reader["UPID"].ToString().Trim() == "0"))
                    {
                        this.DDLMenuType.Items.FindByValue("C").Selected = true;
                        this.txtMenuURL.Enabled = true;
                    }
                    else
                    {
                        this.DDLMenuType.Items.FindByValue("M").Selected = true;
                        this.txtMenuURL.Enabled = false;
                    }
                    this.RBLLookType.Items.FindByValue(reader["IsShow"].ToString()).Selected = true;
                    this.RBLChildMenuTrget.Items.FindByValue(reader["TrgetFlag"].ToString()).Selected = true;
                    this.RBLChildIsHide.Items.FindByValue(reader["IsHide"].ToString()).Selected = true;
                    this.txtMenuURL.Text = reader["MenuURL"].ToString();
                    this.txtMenuName.Text = reader["MenuTitle"].ToString();
                    this.labID.Text = reader["ID"].ToString();
                    this.strBrowUserCode = reader["BrowUserCode"].ToString().Substring(1, reader["BrowUserCode"].ToString().Length - 2);
                    this.strBrowUserName = reader["BrowUserName"].ToString().Substring(1, reader["BrowUserName"].ToString().Length - 2);
                    this.strCMenuICO = reader["MenuICO"].ToString();
                    this.strCMenuICOFile = reader["MenuICO"].ToString();
                    this.txtSortInfo.Text = reader["MenuSort"].ToString();
                    this.strID = this.labID.Text;
                }
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
                this.butDefault.Text = "修 改";
            }
        }
        //protected void TreeMenu_SelectedNodeChanged(object sender, EventArgs e)
        //{
        //    TreeNode selectedNode = this.TreeMenu.SelectedNode;
        //    if (!(selectedNode.Text != "系统菜单信息管理"))
        //    {
        //        this.DDLUPMenu.SelectedIndex = 0;
        //        this.DDLMenuType.SelectedIndex = 0;
        //        this.RBLLookType.SelectedIndex = 0;
        //        this.RBLChildMenuTrget.SelectedIndex = 0;
        //        this.RBLChildIsHide.SelectedIndex = 0;
        //        this.txtMenuURL.Text = "";
        //        this.txtMenuName.Text = "";
        //        this.labID.Text = "0";
        //        this.strBrowUserCode = "所有人员";
        //        this.strBrowUserName = "所有人员";
        //        this.strCMenuICO = "";
        //        this.strCMenuICOFile = "";
        //        this.txtSortInfo.Text = "1";
        //        this.butDefault.Text = "新 增";
        //        this.strID = this.labID.Text;
        //    }
        //    else
        //    {
        //        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
        //        connection.Open();
        //        SqlCommand command = new SqlCommand("select * from SysMenu where ID='" + selectedNode.Value.Trim() + "'", connection);
        //        SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
        //        if (reader.Read())
        //        {
        //            this.DDLUPMenu.SelectedIndex = -1;
        //            this.DDLMenuType.SelectedIndex = -1;
        //            this.RBLLookType.SelectedIndex = -1;
        //            this.RBLChildMenuTrget.SelectedIndex = -1;
        //            this.RBLChildIsHide.SelectedIndex = -1;
        //            this.DDLUPMenu.Items.FindByValue(reader["UPID"].ToString()).Selected = true;
        //            if (!(reader["UPID"].ToString().Trim() == "0"))
        //            {
        //                this.DDLMenuType.Items.FindByValue("C").Selected = true;
        //            }
        //            else
        //            {
        //                this.DDLMenuType.Items.FindByValue("M").Selected = true;
        //            }
        //            this.RBLLookType.Items.FindByValue(reader["IsShow"].ToString()).Selected = true;
        //            this.RBLChildMenuTrget.Items.FindByValue(reader["TrgetFlag"].ToString()).Selected = true;
        //            this.RBLChildIsHide.Items.FindByValue(reader["IsHide"].ToString()).Selected = true;
        //            this.txtMenuURL.Text = reader["MenuURL"].ToString();
        //            this.txtMenuName.Text = reader["MenuTitle"].ToString();
        //            this.labID.Text = reader["ID"].ToString();
        //            this.strBrowUserCode = reader["BrowUserCode"].ToString().Substring(1, reader["BrowUserCode"].ToString().Length - 2);
        //            this.strBrowUserName = reader["BrowUserName"].ToString().Substring(1, reader["BrowUserName"].ToString().Length - 2);
        //            this.strCMenuICO = reader["MenuICO"].ToString();
        //            this.strCMenuICOFile = reader["MenuICO"].ToString();
        //            this.txtSortInfo.Text = reader["MenuSort"].ToString();
        //            this.strID = this.labID.Text;
        //        }
        //        reader.Close();
        //        command.Dispose();
        //        connection.Close();
        //        connection.Dispose();
        //        this.butDefault.Text = "修 改";
        //    }
        //}
    }
}

